<template>
  <div class="list">
    <vue-seamless-scroll :data="list" :class-option="optionTop" class="seamless-warp">
      <ul>
        <li v-for="(item, index) of list" :key="index">
          <div class="item">
            <span class="dot" :class="getDotClass(item.msgCategory)"></span>
            <span class="name">{{ item.titile }}</span>
            <span class="type" :class="getTypeClass(item.msgCategory)">{{ item.msgCategory_dictText }}</span>
            <span class="time">{{ item.createTime.substring(0,10) }}</span>
          </div>
        </li>
      </ul>
    </vue-seamless-scroll>
  </div>
</template>

<script>
import {getAction } from '@/api/manage'
export default {
  data() {
    return {
      url:"/sys/annountCement/list",
      list: [],
    }
  },
  computed: {
    optionTop() {
      return {
        step: 1, // 数值越大速度滚动越快
        limitMoveNum: 5, // 开始无缝滚动的数据量 this.dataList.length
        hoverStop: true, // 是否开启鼠标悬停stop
        direction: 1, // 0向下 1向上 2向左 3向右
        openWatch: true, // 开启数据实时监控刷新dom
        singleHeight: 40, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
        singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
        waitTime: 1000, // 单步运动停止的时间(默认值1000ms)
      }
    },
  },
  mounted(){
    getAction(this.url, {pageNo: 1,pageSize: 50}).then((res) => {
        if (res.success) {
          this.list = res.result.records||res.result;
        }else{
          this.$message.warning(res.message)
        }
      })
  },
  methods:{
    getDotClass(type){
      switch(type){
        case '1':
          return 'dot-yellow';
        case '2':
          return 'dot-orange';
        case '3':
          return 'dot-green';
        case '4':
          return 'dot-blue';
      }
    },
    getTypeClass(type){
      switch(type){
        case '1':
          return 'bg-yellow';
        case '2':
          return 'bg-orange';
        case '3':
          return 'bg-green';
        case '4':
          return 'bg-blue';
      }
    },
  }

}
</script>

<style lang="less" scoped>
.list {
  height: 200px;
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  padding: 9px 10px;
  .seamless-warp {
    flex: 1;
    overflow-y: hidden;

    ul {
      display: flex;
      flex-direction: column;
      list-style: none !important;
      padding: 0;
      margin: 0;
      li {
        .item {
          background: url('../../assets/dasboard/bg-activity.png') no-repeat;
          background-size: 100% 100%;
          padding: 8px;
          display: flex; 
          align-items: center; 
          margin-bottom: 8px;
          .dot {
            height: 10px;
            width: 10px;
            border: 2px solid;
            border-radius: 10px;
          }
          .dot-green {
            border-color: #2db92d;
          }
          .dot-blue {
            border-color: #296bff;
          }
          .dot-orange {
            border-color: #ff6633;
          }
          .dot-yellow {
            border-color: #f5ad0b;
          }
          .bg-green {
            background: #2db92d3b!important;
            color: #2db92d!important;
          }
          .bg-blue {
            background: #1e71ff3b!important;
            color: #1e70ff!important;
          }
          .bg-orange {
            background: #ff66333b!important;
            color: #ff6633!important;
          }
          .bg-yellow {
            background: #f5ad0b3b!important;
            color: #f5ad0b!important;
          }
          .name {
            font-family: 'MiSans';
            font-weight: 400;
            font-size: 14px;
            text-align: left;
            color: #575f6e;
            flex: 1;
            margin: 0 10px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
          .type {
            border-radius: 4px;
            background: #1e71ff3b;
            font-family: 'MiSans';
            font-weight: 400;
            font-size: 12px;
            color: #1e70ff;
            padding: 3px 5px;
          }
          .time {
            font-size: 12px;  
            color: #3b4f5d;
            opacity: 0.5;
            margin: 0 10px;
          }
        }
      }
    }
  }
}
</style>